package com.shortlink.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shortlink.admin.dto.req.recyclebin.RecycleBinPageReqDTO;
import com.shortlink.admin.dto.resp.shortlink.ShortLinkVO;
import com.shortlink.admin.service.RecycleBinService;
import com.shortlink.common.base.Result;
import com.shortlink.common.base.Results;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 回收站管理控制层
 *
 * @author wp
 */
@RestController
@RequiredArgsConstructor
public class RecycleBinController {
    private final RecycleBinService recycleBinService;

    /**
     * 用户分页查询回收站短链接
     */
    @GetMapping("/web-api/recycle/page")
    public Result<IPage<ShortLinkVO>> pageShortLink(RecycleBinPageReqDTO recycleBinPage) {
        return Results.success(recycleBinService.page(recycleBinPage));
    }

    /**
     * 用户恢复短链接
     */
    @PostMapping("/web-api/recycle/recover/{id}")
    public Result<Void> recover(@PathVariable Long id) {
        recycleBinService.recover(id);
        return Results.success();
    }

    /**
     * 用户移除短链接
     */
    @DeleteMapping("/web-api/recycle/delete/{id}")
    public Result<Void> removeRecycleBin(@PathVariable Long id) {
        recycleBinService.delete(id);
        return Results.success();
    }
}
